import { Role } from "@/api/interface/systemRole";
import { DRAGON_ADMIN } from "@/api/config/servicePort";
import http from "@/api";

// 获取角色列表
export const getRoleListApi = (params?: Role.RoleListReq) => {
  return http.get<Role.RoleListRes[]>(DRAGON_ADMIN + `/api/system/role/list`, params);
};

// 获取角色详情
export const getRoleDetailApi = (roleId: number) => {
  return http.get<Role.RoleDetailRes>(DRAGON_ADMIN + `/api/system/role/detail`, { roleId: roleId });
};

// 新增角色
export const addRoleApi = (params: Role.RoleDetailRes) => {
  return http.post<void>(DRAGON_ADMIN + `/api/system/role/add`, params);
};

// 编辑角色
export const editRoleApi = (params: Role.RoleDetailRes) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/role/edit`, params);
};

// 删除角色
export const deleteRoleApi = (roleId: number) => {
  return http.delete<void>(DRAGON_ADMIN + `/api/system/role/delete`, { roleId: roleId });
};

// 更改角色状态
export const changeRoleStatusApi = (params: Role.RoleChangeStatusReq) => {
  return http.put<void>(DRAGON_ADMIN + `/api/system/role/changeStatus`, params);
};

// 获取角色授权用户列表
export const getRoleAuthUserApi = (params: Role.RoleAuthUserReq) => {
  return http.get<void>(DRAGON_ADMIN + `/api/system/role/authUserList`, params);
};

// 获取角色允许授权用户列表
export const getRoleAllowAuthUserApi = (params: Role.RoleAuthUserReq) => {
  return http.get<void>(DRAGON_ADMIN + `/api/system/role/allowAuthUserList`, params);
};

// 批量添加角色授权用户请求参数
export const addRoleAuthUserBatchApi = (params: Role.RoleAuthUserAddBatchReq) => {
  return http.post<void>(DRAGON_ADMIN + `/api/system/role/addAuthUserBatch`, params);
};

// 批量删除角色授权用户请求参数
export const deleteRoleAuthUserBatchApi = (params: Role.RoleAuthUserDeleteBatchReq) => {
  return http.post<void>(DRAGON_ADMIN + `/api/system/role/deleteAuthUserBatch`, params);
};
